package org.brownflat.watergate.dao;

import org.brownflat.watergate.domain.Commit;
import org.brownflat.watergate.domain.Review;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>&copy Rupert Jones 2012</p>
 *
 * @author rup
 */
@Repository
public class ReviewDAO extends AbstractHibernateDAO<Review> {
    public ReviewDAO() {
        super(Review.class);
    }

    public List<Review> findByCommit(Commit commit) {
        List<Review> results = new ArrayList<Review>();

        for (Review review : findAll()) {
            if(review.hasCommit(commit)) {
                results.add(review);
            }
        }
        return results;
    }
}
